/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
  let p1 = 0;
  for (let i = 1; i < nums.length; i++) {
    if (nums[p1] !== nums[i]) {
      p1++;
      nums[p1] = nums[i];
    }
  }
  nums.length = p1 + 1;
  return p1 + 1;
};
